/*
 * Created by JFormDesigner on Sun Jun 26 02:39:29 CST 2022
 */

package com.keshe.jsp;

import com.keshe.service.RoomContorller;
import com.keshe.service.RoomInContorller;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.GroupLayout;
import javax.swing.table.*;

/**
 * @author 1
 */
public class Index extends JFrame {
    public Index() {
        initComponents();
        RoomContorller rc=new RoomContorller();
        table1.setModel(new DefaultTableModel(
                rc.showALL(),
                new String[] {
                        "\u5ba2\u623f\u7f16\u53f7", "\u5ba2\u623f\u7c7b\u578b", "\u4f4d\u7f6e", "\u4ef7\u683c", "\u623f\u95f4\u9762\u79ef", "\u662f\u5426\u7a7a\u95f2", "\u6e05\u6d01\u72b6\u51b5", "\u63cf\u8ff0"
                }
        ));
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");
        panel1 = new JPanel();
        scrollPane1 = new JScrollPane();
        table1 = new JTable();
        panel3 = new JPanel();
        button1 = new JButton();
        button2 = new JButton();
        button3 = new JButton();
        button4 = new JButton();
        button7 = new JButton();
        button8 = new JButton();
        label1 = new JLabel();
        button5 = new JButton();
        button6 = new JButton();
        action1 = new showALL();
        action2 = new login_out();
        action3 = new addRoom();
        action4 = new updataRoom();
        action5 = new selectRoom();
        action6 = new userManage();
        action7 = new ADDRoomin();
        action8 = new showroomin();

        //======== this ========
        setIconImage(new ImageIcon(getClass().getResource("/images/\u9152\u5e97 (1).png")).getImage());
        setTitle("\u9152\u5e97\u5ba2\u623f\u7ba1\u7406\u7cfb\u7edf");
        Container contentPane = getContentPane();

        //======== panel1 ========
        {

            //======== scrollPane1 ========
            {

                //---- table1 ----
                table1.setModel(new DefaultTableModel(
                    new Object[][] {
                        {null, null, null, null, null, null, null, null},
                        {null, null, null, null, null, null, null, null},
                    },
                    new String[] {
                        "\u5ba2\u623f\u7f16\u53f7", "\u5ba2\u623f\u7c7b\u578b", "\u4f4d\u7f6e", "\u4ef7\u683c", "\u623f\u95f4\u9762\u79ef", "\u662f\u5426\u7a7a\u95f2", "\u6e05\u6d01\u72b6\u51b5", "\u63cf\u8ff0"
                    }
                ));
                table1.setSurrendersFocusOnKeystroke(true);
                table1.setAutoCreateRowSorter(true);
                scrollPane1.setViewportView(table1);
            }

            //======== panel3 ========
            {

                //---- button1 ----
                button1.setAction(action5);
                button1.setIcon(new ImageIcon(getClass().getResource("/images/ico_\u6570\u636e\u67e5\u8be2\u4e0e\u7edf\u8ba1_\u9152\u5e97\u623f\u95f4\u5165\u4f4f\u7edf\u8ba1 (1).png")));

                //---- button2 ----
                button2.setAction(action7);
                button2.setIcon(new ImageIcon(getClass().getResource("/images/\u623f\u95f4\u9884\u8ba2_\u753b\u677f 1.png")));

                //---- button3 ----
                button3.setAction(action3);
                button3.setIcon(new ImageIcon(getClass().getResource("/images/1\u6dfb\u52a0.png")));

                //---- button4 ----
                button4.setAction(action4);
                button4.setIcon(new ImageIcon(getClass().getResource("/images/\u623f\u95f4\u7ef4\u62a4.png")));

                //---- button7 ----
                button7.setAction(action6);
                button7.setText("\u8d26\u53f7\u7ba1\u7406");
                button7.setActionCommand("\u8d26\u53f7\u7ba1\u7406");
                button7.setIcon(new ImageIcon(getClass().getResource("/images/\u8d26\u53f7\u7ba1\u7406.png")));
                button7.setSelectedIcon(new ImageIcon(getClass().getResource("/images/\u4eba\u7269-\u8d26\u53f7\u7ba1\u7406.png")));

                //---- button8 ----
                button8.setAction(action8);
                button8.setIcon(new ImageIcon(getClass().getResource("/images/\u597d\u623f\u62d3 4.0.0 iconfont 2_\u5165\u4f4f\u65f6\u95f4.png")));

                GroupLayout panel3Layout = new GroupLayout(panel3);
                panel3.setLayout(panel3Layout);
                panel3Layout.setHorizontalGroup(
                    panel3Layout.createParallelGroup()
                        .addComponent(button8, GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
                        .addComponent(button7, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button4, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button2, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                );
                panel3Layout.setVerticalGroup(
                    panel3Layout.createParallelGroup()
                        .addGroup(panel3Layout.createSequentialGroup()
                            .addComponent(button1, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(button2, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(button3, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(button4, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(button8, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(button7, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                );
            }

            //---- label1 ----
            label1.setText(bundle.getString("label1.text_11"));
            label1.setIcon(new ImageIcon(getClass().getResource("/images/\u767e\u671b\u4e91-\u884c\u4e1a-\u9152\u5e97s (2).png")));
            label1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 48));
            label1.setHorizontalAlignment(SwingConstants.CENTER);

            //---- button5 ----
            button5.setAction(action1);

            //---- button6 ----
            button6.setAction(action2);

            GroupLayout panel1Layout = new GroupLayout(panel1);
            panel1.setLayout(panel1Layout);
            panel1Layout.setHorizontalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(panel1Layout.createParallelGroup()
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addComponent(label1, GroupLayout.DEFAULT_SIZE, 1094, Short.MAX_VALUE)
                                .addContainerGap())
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addComponent(panel3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(panel1Layout.createParallelGroup()
                                    .addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(button5)
                                        .addGap(48, 48, 48)
                                        .addComponent(button6)
                                        .addGap(34, 34, 34))
                                    .addGroup(panel1Layout.createSequentialGroup()
                                        .addGap(9, 9, 9)
                                        .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 879, Short.MAX_VALUE))))))
            );
            panel1Layout.setVerticalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(label1, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addGroup(panel1Layout.createParallelGroup()
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 396, GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(panel1Layout.createParallelGroup()
                                    .addComponent(button6)
                                    .addComponent(button5))
                                .addGap(12, 12, 12))
                            .addGroup(panel1Layout.createSequentialGroup()
                                .addComponent(panel3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addContainerGap())))
            );
        }

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addComponent(panel1, GroupLayout.PREFERRED_SIZE, 598, GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 5, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JPanel panel1;
    private JScrollPane scrollPane1;
    private JTable table1;
    private JPanel panel3;
    private JButton button1;
    private JButton button2;
    private JButton button3;
    private JButton button4;
    private JButton button7;
    private JButton button8;
    private JLabel label1;
    private JButton button5;
    private JButton button6;
    private showALL action1;
    private login_out action2;
    private addRoom action3;
    private updataRoom action4;
    private selectRoom action5;
    private userManage action6;
    private ADDRoomin action7;
    private showroomin action8;
    // JFormDesigner - End of variables declaration  //GEN-END:variables

    private class showALL extends AbstractAction {
        private showALL() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action1.Name_10"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            RoomContorller rc=new RoomContorller();
            table1.setModel(new DefaultTableModel(
                    rc.showALL(),
                    new String[] {
                            "\u5ba2\u623f\u7f16\u53f7", "\u5ba2\u623f\u7c7b\u578b", "\u4f4d\u7f6e", "\u4ef7\u683c", "\u623f\u95f4\u9762\u79ef", "\u662f\u5426\u7a7a\u95f2", "\u6e05\u6d01\u72b6\u51b5", "\u63cf\u8ff0"
                    }
            ));
        }
    }

    private class login_out extends AbstractAction {
        private login_out() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action2.Name_4"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            System.exit(0);
        }
    }

    private class addRoom extends AbstractAction {
        private addRoom() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action3.Name"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();
            new AddRoom().setVisible(true);
        }
    }

    private class updataRoom extends AbstractAction {
        private updataRoom() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action4.Name_2"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();
            new UpdateRoom().setVisible(true);
        }
    }

    private class selectRoom extends AbstractAction {
        private selectRoom() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action5.Name"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();//关闭当前页面
            new SelectRoom().setVisible(true);
        }
    }

    private class userManage extends AbstractAction {
        private userManage() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action6.Name"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();
            new UserManager().setVisible(true);
        }
    }

    private class ADDRoomin extends AbstractAction {
        private ADDRoomin() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action7.Name"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            new RoomInSet().setVisible(true);
            dispose();
        }
    }

    private class showroomin extends AbstractAction {
        private showroomin() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action8.Name"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            RoomInContorller ri=new RoomInContorller();
            table1.setModel(new DefaultTableModel(
                    ri.showALL(),
                    new String[] {
                            "房间编号", "入住人姓名", "入住人身份证号", "入住时间", "退房时间", "入住天数","交付押金"
                    }
            ));
        }
    }
}
